﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtDepartureDate.Text = "20/12/2014";
                txtReturnDate.Text = "25/12/2014";
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string startPoint = hdnValueStartPoint.Value;
            string endPoint = hdnValueEndPoint.Value;

            //Làm thế này mới chạy được nhiều tab trên 1 trình duyệt và đặt booking chính xác
            string searchCondition =
                startPoint
                + "-" + endPoint
                + "-" + txtDepartureDate.Text
                + "-" + txtReturnDate.Text
                + "-" + ddlAdt.SelectedValue
                + "-" + ddlChd.SelectedValue
                + "-" + ddlInf.SelectedValue
                + "-" + rdbOneWay.Checked;

            searchCondition = searchCondition.Replace("/", "");

            Session[searchCondition + "Departure"] = startPoint;
            Session[searchCondition + "Destination"] = endPoint;
            Session[searchCondition + "DepartureDate"] = txtDepartureDate.Text;
            Session[searchCondition + "ReturnDate"] = txtReturnDate.Text;
            Session[searchCondition + "Adt"] = ddlAdt.SelectedValue;
            Session[searchCondition + "Chd"] = ddlChd.SelectedValue;
            Session[searchCondition + "Inf"] = ddlInf.SelectedValue;
            Session[searchCondition + "ItineraryType"] = rdbOneWay.Checked; //True is one way, False is round trip

            Response.Redirect("/Result.aspx?SearchCondition=" + searchCondition);
        }
    }
}